﻿/* ***********************************************************************************************
 * Oak_DynamicSeek
 * Version: 1.0
 * Author:  BRyan Solero  
 * Email:  arindil@gmail.com
 * Copyright 2012.  All Rights Reserved.
 * 
 * ************************************************************************************************/
using System;
using Microsoft.Xna.Framework;


namespace OakEngine.AI.Dynamic_Steering_Behavior
{
   public class Oak_DynamicSeek : Oak_DynBehavior
   {
       private Vector2 m_Target;
       private float m_fSpeed;

       #region Prop

       public float Speed { get { return m_fSpeed; } set { m_fSpeed = value; } }
       public Vector2 Target { get { return m_Target; } set { m_Target = value; } }
       
       #endregion

       #region Constructor
       public Oak_DynamicSeek()
       {
           m_Target = Vector2.Zero;
           m_fSpeed = 0.0f;
       }

       public Oak_DynamicSeek(Vector2 target)
       {
           m_Target = target;
           m_fSpeed = 0.0f;
       }

       public Oak_DynamicSeek(Vector2 target, float speed)
       {
           m_Target = target;
           m_fSpeed = speed;
       } 
       #endregion

       #region Method
       public override void UpdateSteeringMovement(Steering.Oak_Steering steer)
       {
           steer.ForwardVector = m_Target;
           steer.ForwardVector -= this.BehaviorAgent.Position;

           if (OakEngine.AI.Tools.OAK_AITools.SquareMagnitude(steer.ForwardVector) > 0)
           {
               steer.ForwardVector = Vector2.Normalize(steer.ForwardVector);
               steer.ForwardVector *= m_fSpeed;
           }
       } 
       #endregion
    }
}
